package Access;

import Entities.Album;
import ExtEntities.ExtAlbum;
import Special.SpecialAccessor;
import Special.SpecialComposition;
import Special.SpecialGenre;
import Special.SpecialRecording;
import Special.SpecialUser;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;

/**
 *
 * @author 647_2
 */
@Stateless
public class Special implements SpecialRemote {
    public LinkedList<SpecialGenre> getCountCompositionInGenres(){
        try {
            return SpecialAccessor.getCountCompositionInGenres();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public LinkedList<SpecialRecording> getCountCompositionsAndAlbumsInRecording() {
        try {
            return SpecialAccessor.getCountCompositionsAndAlbumsInRecording();
        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public LinkedList<SpecialComposition> getCompositionsWithManyGenres() {
        try {
            return SpecialAccessor.getCompositionsWithManyGenres();
        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public SpecialUser getActiveUser(){
        try {
            return SpecialAccessor.getActiveUser();
        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public LinkedList<ExtAlbum> getAlbumsByExecutorID(int eID) {
        try {
            LinkedList<Album> albums = SpecialAccessor.getAlbumsByExecutorID(eID);

            LinkedList<ExtAlbum> ealbums = new LinkedList<ExtAlbum>();

            for (int i = 0; i < albums.size(); i++){
                ealbums.add((new Albums()).getAlbum(albums.get(i).getIDAsInt()));
            }

            return ealbums;

        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public ExtAlbum getGreatableAlbum() {
        try {
            Album album = SpecialAccessor.getGreatableAlbum();
            return (new Albums()).getAlbum(album.getIDAsInt());
        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public int getCountAlbumsByGroupIDAndCountryID(int gID, int cID) {
        try {
            return SpecialAccessor.getCountAlbumsByGroupIDAndCountryID(gID, cID);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Special.class.getName()).log(Level.SEVERE, null, ex);
        }

        return 0;
    }
 
}
